<!DOCTYPE html>
<html class="writer-html5" lang="en">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>selenium_driverless.types.options &mdash; Selenium-Driverless 1.9.4 documentation</title>
      <link rel="stylesheet" type="text/css" href="../../../_static/pygments.css?v=80d5e7a1" />
      <link rel="stylesheet" type="text/css" href="../../../_static/css/theme.css?v=19f00094" />

  
  <!--[if lt IE 9]>
    <script src="../../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
        <script src="../../../_static/jquery.js?v=5d32c60e"></script>
        <script src="../../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
        <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js?v=1ac0efc4"></script>
        <script src="../../../_static/doctools.js?v=888ff710"></script>
        <script src="../../../_static/sphinx_highlight.js?v=4825356b"></script>
    <script src="../../../_static/js/theme.js"></script>
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" /> 
</head>

<body class="wy-body-for-nav"> 
  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >

          
          
          <a href="../../../index.html" class="icon icon-home">
            Selenium-Driverless
          </a>
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
        </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
              <ul>
<li class="toctree-l1"><a class="reference internal" href="../../../api/By.html">By Element Locator</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/Chrome.html">webdriver.Chrome</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/ChromeOptions.html">ChromeOptions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/Context.html">Context</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/Input.html">Input</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/RequestInterception.html">Request-Interception</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/Target.html">Target</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/WebELement.html">WebElement</a></li>
</ul>

        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../../index.html">Selenium-Driverless</a>
      </nav>

      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../../index.html" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../../index.html">Module code</a></li>
      <li class="breadcrumb-item active">selenium_driverless.types.options</li>
      <li class="wy-breadcrumbs-aside">
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             
  <h1>Source code for selenium_driverless.types.options</h1><div class="highlight"><pre>
<span></span><span class="c1"># Licensed to the Software Freedom Conservancy (SFC) under one</span>
<span class="c1"># or more contributor license agreements.  See the NOTICE file</span>
<span class="c1"># distributed with this work for additional information</span>
<span class="c1"># regarding copyright ownership.  The SFC licenses this file</span>
<span class="c1"># to you under the Apache License, Version 2.0 (the</span>
<span class="c1"># &quot;License&quot;); you may not use this file except in compliance</span>
<span class="c1"># with the License.  You may obtain a copy of the License at</span>
<span class="c1">#</span>
<span class="c1">#   http://www.apache.org/licenses/LICENSE-2.0</span>
<span class="c1">#</span>
<span class="c1"># Unless required by applicable law or agreed to in writing,</span>
<span class="c1"># software distributed under the License is distributed on an</span>
<span class="c1"># &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY</span>
<span class="c1"># KIND, either express or implied.  See the License for the</span>
<span class="c1"># specific language governing permissions and limitations</span>
<span class="c1"># under the License.</span>
<span class="c1">#</span>
<span class="c1"># modified by kaliiiiiiiiii | Aurin Aegerter</span>
<span class="c1"># all modifications are licensed under the license provided at LICENSE.md</span>

<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">pathlib</span>
<span class="kn">import</span> <span class="nn">warnings</span>
<span class="kn">from</span> <span class="nn">abc</span> <span class="kn">import</span> <span class="n">ABCMeta</span>
<span class="kn">import</span> <span class="nn">typing</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Union</span><span class="p">,</span> <span class="n">Optional</span><span class="p">,</span> <span class="n">List</span>
<span class="kn">from</span> <span class="nn">selenium_driverless.scripts.prefs</span> <span class="kn">import</span> <span class="n">prefs_to_json</span>


<span class="c1"># noinspection PyUnreachableCode,PyUnusedLocal</span>
<div class="viewcode-block" id="Options"><a class="viewcode-back" href="../../../api/ChromeOptions.html#selenium_driverless.types.options.Options">[docs]</a><span class="k">class</span> <span class="nc">Options</span><span class="p">(</span><span class="n">metaclass</span><span class="o">=</span><span class="n">ABCMeta</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    the `webdriver.ChromeOptions` class</span>

<span class="sd">    .. warning::</span>

<span class="sd">        options should not be reused</span>

<span class="sd">    &quot;&quot;&quot;</span>

    <span class="n">use_extension</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    don&#39;t add the chrome-extension by default</span>
<span class="sd">    </span>
<span class="sd">    .. warning::</span>
<span class="sd">        setting proxies and auth while running requires the extension to be added. </span>
<span class="sd">        As an alternative, you might use ``--proxy-server=host:port`` and `Requests-interception &lt;https://kaliiiiiiiiii.github.io/Selenium-Driverless/api/RequestInterception/#request-interception&gt;`_ to provide auth</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_single_proxy</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="kn">from</span> <span class="nn">selenium_driverless.utils.utils</span> <span class="kn">import</span> <span class="n">IS_POSIX</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_proxy</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="c1"># self.set_capability(&quot;pageLoadStrategy&quot;, &quot;normal&quot;)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">mobile_options</span> <span class="o">=</span> <span class="kc">None</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_binary_location</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_env</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_extension_paths</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_extensions</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_experimental_options</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_debugger_address</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_user_data_dir</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_downloads_dir</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_arguments</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_prefs</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s1">&#39;devtools&#39;</span><span class="p">:</span> <span class="p">{</span>
                <span class="s1">&#39;preferences&#39;</span><span class="p">:</span> <span class="p">{</span>
                    <span class="c1"># always open devtools in undocked</span>
                    <span class="s1">&#39;currentDockState&#39;</span><span class="p">:</span> <span class="s1">&#39;&quot;undocked&quot;&#39;</span><span class="p">,</span>
                    <span class="c1"># always open devtools with console open</span>
                    <span class="s1">&#39;panel-selectedTab&#39;</span><span class="p">:</span> <span class="s1">&#39;&quot;console&quot;&#39;</span><span class="p">}</span>
            <span class="p">},</span>
            <span class="s2">&quot;download_bubble&quot;</span><span class="p">:</span> <span class="p">{</span>
                <span class="c1"># don&#39;t Show downloads when they&#39;re done</span>
                <span class="s2">&quot;partial_view_enabled&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
            <span class="p">},</span>
            <span class="s2">&quot;in_product_help&quot;</span><span class="p">:</span> <span class="p">{</span>
                <span class="s2">&quot;snoozed_feature&quot;</span><span class="p">:</span> <span class="p">{</span>
                    <span class="s2">&quot;IPH_HighEfficiencyMode&quot;</span><span class="p">:</span> <span class="p">{</span>
                        <span class="c1"># disable &quot;memory saver&quot;</span>
                        <span class="c1"># instead, limit number of open tabs</span>
                        <span class="c1"># https://github.com/milahu/aiohttp_chromium/blob/61fe3150ed032ef8aa99b23dddbedaa1929c229c/src/aiohttp_chromium/client.py#L1017-L1025</span>
                        <span class="s2">&quot;is_dismissed&quot;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
                    <span class="p">}</span>
                <span class="p">}</span>
            <span class="p">},</span>
            <span class="c1"># disable password manager popup https://stackoverflow.com/a/46602329/20443541</span>
            <span class="s2">&quot;credentials_enable_service&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
            <span class="s2">&quot;profile&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;password_manager_enabled&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span>
        <span class="p">}</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_ignore_local_proxy</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_auto_clean_dirs</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_headless</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_startup_url</span> <span class="o">=</span> <span class="s2">&quot;about:blank&quot;</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">add_arguments</span><span class="p">(</span>
            <span class="s2">&quot;--no-first-run&quot;</span><span class="p">,</span>  <span class="c1"># disable first run page</span>
            <span class="c1"># &#39;--disable-component-update&#39;,  # disable updates, breaks widevine</span>
            <span class="s1">&#39;--no-service-autorun&#39;</span><span class="p">,</span>  <span class="c1"># don&#39;t start a service</span>
            <span class="c1"># don&#39;t auto-reload pages on network errors, https://github.com/milahu/aiohttp_chromium/blob/61fe3150ed032ef8aa99b23dddbedaa1929c229c/src/aiohttp_chromium/client.py#L1116C9-L1118</span>
            <span class="s2">&quot;--disable-auto-reload&quot;</span><span class="p">,</span>
            <span class="c1"># some backgrounding tweaking</span>
            <span class="s1">&#39;--disable-backgrounding-occluded-windows&#39;</span><span class="p">,</span> <span class="s1">&#39;--disable-renderer-backgrounding&#39;</span><span class="p">,</span>
            <span class="s1">&#39;--disable-background-timer-throttling&#39;</span><span class="p">,</span>
            <span class="s1">&#39;--disable-background-networking&#39;</span><span class="p">,</span> <span class="s1">&#39;--no-pings&#39;</span><span class="p">,</span>
            <span class="s1">&#39;--disable-infobars&#39;</span><span class="p">,</span> <span class="s1">&#39;--disable-breakpad&#39;</span><span class="p">,</span>  <span class="c1"># some bars tweak</span>
            <span class="s2">&quot;--no-default-browser-check&quot;</span><span class="p">,</span>  <span class="c1"># disable default browser message</span>
            <span class="s1">&#39;--homepage=about:blank&#39;</span>  <span class="c1"># set homepage</span>
            <span class="s2">&quot;--wm-window-animations-disabled&quot;</span><span class="p">,</span> <span class="s2">&quot;--animation-duration-scale=0&quot;</span><span class="p">,</span>  <span class="c1"># disable animations</span>
            <span class="s2">&quot;--enable-privacy-sandbox-ads-apis&quot;</span><span class="p">,</span>
            <span class="c1"># ensure window.Fence, window.SharedStorage etc. exist, looks like chrome disables them when using automation</span>
            <span class="s2">&quot;--disable-search-engine-choice-screen&quot;</span><span class="p">,</span>  <span class="c1"># for chrome&gt;=127,</span>
            <span class="c1"># &quot;--enable-field-trial-config&quot;</span>
            <span class="c1"># https://source.chromium.org/chromium/chromium/src/+/main:components/variations/variations_url_constants.cc</span>
            <span class="c1"># &quot;--variations-server-url=https://clientservices.googleapis.com/chrome-variations/seed&quot;</span>
        <span class="p">)</span>
        <span class="k">if</span> <span class="n">IS_POSIX</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">&quot;--password-store=basic&quot;</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_is_remote</span> <span class="o">=</span> <span class="kc">True</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">arguments</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">typing</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        used arguments for the chrome executable</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_arguments</span>

<div class="viewcode-block" id="Options.add_argument"><a class="viewcode-back" href="../../../api/ChromeOptions.html#selenium_driverless.types.options.Options.add_argument">[docs]</a>    <span class="k">def</span> <span class="nf">add_argument</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">argument</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Adds an argument for launching chrome</span>

<span class="sd">        :param argument: argument to add</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="kn">import</span> <span class="nn">os</span>
        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">argument</span><span class="p">)</span> <span class="ow">is</span> <span class="nb">str</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">argument</span><span class="p">[:</span><span class="mi">16</span><span class="p">]</span> <span class="o">==</span> <span class="s2">&quot;--user-data-dir=&quot;</span><span class="p">:</span>
                <span class="n">user_data_dir</span> <span class="o">=</span> <span class="n">argument</span><span class="p">[</span><span class="mi">16</span><span class="p">:]</span>
                <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">user_data_dir</span><span class="p">):</span>
                    <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">user_data_dir</span><span class="p">,</span> <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_user_data_dir</span> <span class="o">=</span> <span class="n">user_data_dir</span>
            <span class="k">elif</span> <span class="n">argument</span><span class="p">[:</span><span class="mi">24</span><span class="p">]</span> <span class="o">==</span> <span class="s2">&quot;--remote-debugging-port=&quot;</span><span class="p">:</span>
                <span class="n">port</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">argument</span><span class="p">[</span><span class="mi">24</span><span class="p">:])</span>
                <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_debugger_address</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">_debugger_address</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">&quot;127.0.0.1:</span><span class="si">{</span><span class="n">port</span><span class="si">}</span><span class="s2">&quot;</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_is_remote</span> <span class="o">=</span> <span class="kc">False</span>
            <span class="k">elif</span> <span class="n">argument</span><span class="p">[:</span><span class="mi">17</span><span class="p">]</span> <span class="o">==</span> <span class="s2">&quot;--load-extension=&quot;</span><span class="p">:</span>
                <span class="n">extensions</span> <span class="o">=</span> <span class="n">argument</span><span class="p">[</span><span class="mi">17</span><span class="p">:]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;,&quot;</span><span class="p">)</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_extension_paths</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">extensions</span><span class="p">)</span>
                <span class="k">return</span>
            <span class="k">elif</span> <span class="n">argument</span><span class="p">[:</span><span class="mi">10</span><span class="p">]</span> <span class="o">==</span> <span class="s2">&quot;--headless&quot;</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_headless</span> <span class="o">=</span> <span class="kc">True</span>
                <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">argument</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">10</span> <span class="ow">and</span> <span class="n">argument</span><span class="p">[</span><span class="mi">11</span><span class="p">:]</span> <span class="o">==</span> <span class="s2">&quot;new&quot;</span><span class="p">):</span>
                    <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
                        <span class="s1">&#39;headless without &quot;--headless=new&quot; might be buggy, makes you detectable &amp; breaks proxies&#39;</span><span class="p">,</span>
                        <span class="ne">DeprecationWarning</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_arguments</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">argument</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;argument has to be str&quot;</span><span class="p">)</span></div>

<div class="viewcode-block" id="Options.add_arguments"><a class="viewcode-back" href="../../../api/ChromeOptions.html#selenium_driverless.types.options.Options.add_arguments">[docs]</a>    <span class="k">def</span> <span class="nf">add_arguments</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">arguments</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;add multiple arguments</span>

<span class="sd">        :param arguments: arguments to add</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">arguments</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span></div>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">prefs</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">dict</span><span class="p">:</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;the preferences as json&quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prefs</span>

<div class="viewcode-block" id="Options.update_pref"><a class="viewcode-back" href="../../../api/ChromeOptions.html#selenium_driverless.types.options.Options.update_pref">[docs]</a>    <span class="k">def</span> <span class="nf">update_pref</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">pref</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;update a preference</span>

<span class="sd">        :param pref: name of the preference (&quot;.&quot; dot path)</span>
<span class="sd">        :param value: the value to set the preference to</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_prefs</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">prefs_to_json</span><span class="p">({</span><span class="n">pref</span><span class="p">:</span> <span class="n">value</span><span class="p">}))</span></div>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">user_data_dir</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;the directory to save all browser data in.</span>
<span class="sd">        ``None`` (default) will temporarily create a directory in $temp</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_user_data_dir</span>

    <span class="nd">@user_data_dir</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">user_data_dir</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">_dir</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_user_data_dir</span> <span class="o">=</span> <span class="n">_dir</span>
        <span class="k">if</span> <span class="n">_dir</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;--user-data-dir=</span><span class="si">{</span><span class="n">_dir</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">downloads_dir</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;the default directory to download files to.</span>

<span class="sd">        .. code-block:: python</span>

<span class="sd">            _dir = os.getcwd()+&quot;/downloads&quot;</span>
<span class="sd">            if not os.path.isdir(_dir):</span>
<span class="sd">                os.mkdir(_dir)</span>
<span class="sd">            options = webdriver.ChromeOptions()</span>
<span class="sd">            options.downloads_dir = _dir</span>
<span class="sd">            options.update_pref(&quot;plugins.always_open_pdf_externally&quot;, True)</span>
<span class="sd">            async with webdriver.Chrome(options=options) as driver:</span>
<span class="sd">                download_data = await driver.get(&#39;https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf&#39;, timeout=5)</span>
<span class="sd">                print(download_data.get(&quot;guid_file&quot;))</span>

<span class="sd">        .. warning::</span>
<span class="sd">            path has to be absolute</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_downloads_dir</span>

    <span class="nd">@downloads_dir</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">downloads_dir</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">directory_path</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">directory_path</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_downloads_dir</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">_dir</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="n">directory_path</span><span class="p">))</span>
            <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">_dir</span><span class="p">):</span>
                <span class="k">raise</span> <span class="ne">OSError</span><span class="p">(</span><span class="s2">&quot;path can&#39;t point to a file&quot;</span><span class="p">)</span>
            <span class="k">elif</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">_dir</span><span class="p">):</span>
                <span class="k">pass</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">os</span><span class="o">.</span><span class="n">mkdir</span><span class="p">(</span><span class="n">_dir</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_downloads_dir</span> <span class="o">=</span> <span class="n">_dir</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">headless</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Whether chrome starts headless.</span>
<span class="sd">        defaults to ``False``</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_headless</span>

    <span class="nd">@headless</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">headless</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="nb">bool</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">value</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_headless</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span><span class="s2">&quot;setting headless=True can&#39;t be undone in options atm&quot;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">&quot;--headless=new&quot;</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">startup_url</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        the url the first tab loads.</span>
<span class="sd">        Defaults to ``about:blank``</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_startup_url</span>

    <span class="nd">@startup_url</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">startup_url</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">url</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="kc">None</span><span class="p">]):</span>
        <span class="k">if</span> <span class="n">url</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">url</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_startup_url</span> <span class="o">=</span> <span class="n">url</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">single_proxy</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Set a single proxy to be applied.</span>

<span class="sd">        .. code-block:: python</span>

<span class="sd">            options = webdriver.ChromeOptions()</span>
<span class="sd">            options.single_proxy = &quot;http://user1:passwrd1@example.proxy.com:5001/&quot;</span>

<span class="sd">        .. warning::</span>

<span class="sd">            - Only supported when Chrome has been started with driverless or the extension at ``selenium_driverless/files/mv3_extension`` has been loaded into the browser.</span>

<span class="sd">            - ``Socks5`` doesn&#39;t support authentication due to `crbug#1309413 &lt;https://bugs.chromium.org/p/chromium/issues/detail?id=1309413&gt;`__.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_single_proxy</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">binary_location</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        path to the Chromium binary</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="kn">from</span> <span class="nn">selenium_driverless.utils.utils</span> <span class="kn">import</span> <span class="n">find_chrome_executable</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_binary_location</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_binary_location</span> <span class="o">=</span> <span class="n">find_chrome_executable</span><span class="p">()</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_binary_location</span>

    <span class="nd">@binary_location</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">binary_location</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_binary_location</span> <span class="o">=</span> <span class="n">value</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">env</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;the env for ``subprocess.Popen, ``os.environ`` by default&quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_env</span>

    <span class="nd">@env</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">env</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">env</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_env</span> <span class="o">=</span> <span class="n">env</span>

<div class="viewcode-block" id="Options.add_extension"><a class="viewcode-back" href="../../../api/ChromeOptions.html#selenium_driverless.types.options.Options.add_extension">[docs]</a>    <span class="k">def</span> <span class="nf">add_extension</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Adds an extension to Chrome</span>
<span class="sd">        The extension can either be a compressed file (zip, crx, etc.) or extracted in a directory</span>

<span class="sd">        :param path: path to the extension</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">extension_to_add</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">expanduser</span><span class="p">(</span><span class="n">path</span><span class="p">))</span>
        <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">extension_to_add</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_extension_paths</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">extension_to_add</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">OSError</span><span class="p">(</span><span class="s2">&quot;Path to the extension doesn&#39;t exist&quot;</span><span class="p">)</span></div>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">debugger_address</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        The address of the remote devtools instance in format &quot;host:port&quot;</span>
<span class="sd">        Setting this value makes the driver connect to a remote browser instance (unless you set user-data-dir as well)</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_debugger_address</span>

    <span class="nd">@debugger_address</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">debugger_address</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_debugger_address</span> <span class="o">=</span> <span class="n">value</span>

    <span class="nd">@single_proxy</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">single_proxy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">proxy</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_single_proxy</span> <span class="o">=</span> <span class="n">proxy</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">auto_clean_dirs</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span> <span class="ow">or</span> <span class="kc">None</span><span class="p">:</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;if user-data-dir should be cleaned automatically</span>
<span class="sd">        defaults to True</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_auto_clean_dirs</span>

    <span class="nd">@auto_clean_dirs</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">auto_clean_dirs</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">enabled</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_auto_clean_dirs</span> <span class="o">=</span> <span class="n">enabled</span>

<div class="viewcode-block" id="Options.enable_mobile"><a class="viewcode-back" href="../../../api/ChromeOptions.html#selenium_driverless.types.options.Options.enable_mobile">[docs]</a>    <span class="k">def</span> <span class="nf">enable_mobile</span><span class="p">(</span>
            <span class="bp">self</span><span class="p">,</span>
            <span class="n">android_package</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;com.android.chrome&quot;</span><span class="p">,</span>
            <span class="n">android_activity</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
            <span class="n">device_serial</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
    <span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Enables mobile browser use for browsers that support it.</span>

<span class="sd">        :param android_activity: The name of the android package to start</span>
<span class="sd">        :param android_package:</span>
<span class="sd">        :param device_serial:</span>

<span class="sd">        .. warning::</span>

<span class="sd">            Not Implemented yet</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">android_package</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">AttributeError</span><span class="p">(</span><span class="s2">&quot;android_package must be passed in&quot;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">mobile_options</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;androidPackage&quot;</span><span class="p">:</span> <span class="n">android_package</span><span class="p">}</span>
        <span class="k">if</span> <span class="n">android_activity</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">mobile_options</span><span class="p">[</span><span class="s2">&quot;androidActivity&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">android_activity</span>
        <span class="k">if</span> <span class="n">device_serial</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">mobile_options</span><span class="p">[</span><span class="s2">&quot;androidDeviceSerial&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">device_serial</span></div>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">accept_insecure_certs</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :returns: whether the session accepts insecure certificates</span>

<span class="sd">        .. warning::</span>
<span class="sd">            NotImplemented yet</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_caps</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;acceptInsecureCerts&quot;</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span>

<div class="viewcode-block" id="Options.ignore_local_proxy_environment_variables"><a class="viewcode-back" href="../../../api/ChromeOptions.html#selenium_driverless.types.options.Options.ignore_local_proxy_environment_variables">[docs]</a>    <span class="k">def</span> <span class="nf">ignore_local_proxy_environment_variables</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;By calling this you will ignore HTTP_PROXY and HTTPS_PROXY from</span>
<span class="sd">        being picked up and used.</span>

<span class="sd">        .. warning::</span>
<span class="sd">            NotImplemented yet</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_ignore_local_proxy</span> <span class="o">=</span> <span class="kc">True</span></div>

<div class="viewcode-block" id="Options.add_experimental_option"><a class="viewcode-back" href="../../../api/ChromeOptions.html#selenium_driverless.types.options.Options.add_experimental_option">[docs]</a>    <span class="k">def</span> <span class="nf">add_experimental_option</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]])</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Adds an experimental option which is passed to chromium.</span>

<span class="sd">        .. warning::</span>
<span class="sd">            only ``name=&quot;prefs&quot;`` supported.</span>
<span class="sd">            This method is deprecated and will be removed. Use :obj:`ChromeOptions.update_pref` instead.</span>

<span class="sd">        :param name: The experimental option name.</span>
<span class="sd">        :param value: The option value.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">name</span> <span class="o">==</span> <span class="s2">&quot;prefs&quot;</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">prefs</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">prefs_to_json</span><span class="p">(</span><span class="n">value</span><span class="p">))</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span></div></div>
</pre></div>

           </div>
          </div>
          <footer>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2024, Aurin Aegerter (aka Steve, kaliiiiiiiiii).</p>
  </div>

  Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    provided by <a href="https://readthedocs.org">Read the Docs</a>.
   

</footer>
        </div>
      </div>
    </section>
  </div>
  <script>
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>